package com.xcf.center.client;

public class ServerWrapper<META> {
    private META serverMeta;
    private Long requestNum = 0L;
    private Long lastRequestTime = 0L;
    private Long lastResponseTime = 0L;
    private Long lastHandlerTime;

    public ServerWrapper(META serverMeta) {
        this.serverMeta = serverMeta;
    }

    public META getServerMeta() {
        requestNum++;
        return serverMeta;
    }

    public void setServerMeta(META serverMeta) {
        this.serverMeta = serverMeta;
    }

    public Long getLastRequestTime() {
        return lastRequestTime;
    }

    public void setLastRequestTime(Long lastRequestTime) {
        this.lastRequestTime = lastRequestTime;
    }

    public Long getLastResponseTime() {
        return lastResponseTime;
    }

    public void setLastResponseTime(Long lastResponseTime) {
        this.lastResponseTime = lastResponseTime;
    }

    public Long getLastHandlerTime() {
        if (lastHandlerTime == null) {
            return lastResponseTime - lastRequestTime;
        }
        return lastHandlerTime;
    }

    public void setLastHandlerTime(Long lastHandlerTime) {
        this.lastHandlerTime = lastHandlerTime;
    }

    public Long getRequestNum() {
        return requestNum;
    }

    public void setRequestNum(Long requestNum) {
        this.requestNum = requestNum;
    }
}
